package com.xxx.modules.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xxx.modules.mapper.MonitorMapper;
import com.xxx.modules.entity.Monitor;
import com.xxx.modules.service.MonitorService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.util.Arrays;
import com.xxx.modules.utils.TimeUtil;

/**
 * monitor
 *
 * @author 北易航
 * @since 1.0.0 2023-02-05
 */
@Service
public class MonitorServiceImpl extends ServiceImpl<MonitorMapper, Monitor> implements MonitorService {

    @Autowired
    private MonitorMapper monitorMapper;


    @Override
    public PageInfo<Monitor> selectMonitorInfo(Monitor monitor, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper<Monitor> wrapper = new QueryWrapper<>();
        List<Monitor> data = monitorMapper.selectListInfo(monitor);
        return new PageInfo<>(data);
    }

    @Override
    public void saveMonitorInfo(Monitor monitor) {
        monitor.setCreateTime(TimeUtil.getCurrentTime());
        monitorMapper.insert(monitor);
    }

    @Override
    public void updateMonitorInfo(Monitor monitor) {
        monitorMapper.updateById(monitor);
    }

    @Override
    public void delMonitorInfo(Integer id) {
        monitorMapper.deleteById(id);
    }

    @Override
    public void delBatchMonitorInfo(String idList) {
        List<String> list = Arrays.asList(idList.split(","));
        monitorMapper.deleteBatchIds(list);
    }


}